//
//  ZGWGeXingTianFuOnReportViewController.m
//  1gene
//
//  Created by 张国文 on 16/7/15.
//  Copyright © 2016年 1jiyin. All rights reserved.
//

#import "ZGWGeXingTianFuOnReportViewController.h"
#import "KWFormView.h"
#import "JiYinJianCeJieGuoModel.h"
#import "ZGWBiaoGeXiangJieViewController.h"
#import "ZGWGeneListViewController.h"
#import "ZGWWebViewController.h"

#define kCurrentUserToken [[NSUserDefaults standardUserDefaults]objectForKey:@"token"]

@interface ZGWGeXingTianFuOnReportViewController ()<KWFormViewDataSource, KWFormViewDelegate>

@property (nonatomic, strong) UIScrollView *backGroundScrollview; // 背景滚动图

@property (nonatomic, strong) NSMutableArray *huanBingGaiLv; // 患病概率数组

@property (nonatomic, strong) KWFormView *jiYinBiaoGe; // 基因表

@property (nonatomic, strong) NSMutableArray *jiYinBiaoGeArray; // 基因表数组

@property (nonatomic, strong) NSMutableArray *xiaoLianRectArray; // 笑脸位置

@property (nonatomic, strong) KWFormView *ranSeTiBiaoGe; // 染色体表格

@property (nonatomic, strong) NSMutableArray *ranSeTiImageWeiZhiArray; // 保存染色体位置

@property (nonatomic, strong) NSMutableArray *ranSeTiNameArray; // 染色体名字

@property (nonatomic, strong) NSMutableArray *qiTaZhiBingYinSuArray; // 其他致病因素数组

@property (nonatomic, strong) NSMutableArray *jianKangJianYiArray; // 健康建议的数组

@property (nonatomic, strong) NSString *diseaseIntroduceString; // 疾病介绍

@property (nonatomic, strong) NSMutableArray *jiuZhengZhiArray; // 纠正值数组

@property (nonatomic, assign) CGFloat jiuZhengFengXianJieShaoBottom; // 纠正风险值介绍底部

@property (nonatomic, strong) NSMutableArray *jiYinArray; // 示例报告的基因数据

@property (nonatomic, strong) NSString *imageUrl; // 图片url

@property (nonatomic, strong) NSMutableArray *jvXianXingArray; // 局限性数组

@property (nonatomic, strong) NSMutableArray *danXiangBiaoQianArray; // 单项标签的数组

@property (nonatomic, strong) NSTimer *myTimer; // 检查请求是否超时
@property (nonatomic, assign) NSInteger numberOfTime; // 存储请求时间

@end

@implementation ZGWGeXingTianFuOnReportViewController

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:YES];
    // 关闭动画
    [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] stopAnimation];
    // 关闭计时器
    [self.myTimer invalidate];
    self.numberOfTime = 0;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    // navi的修改
    [self changeNavigation];
    
    // 检查网络并建立数据源
    [self searchNetAndAddData];
}

// navi的修改
- (void)changeNavigation
{
    //  self.navigationItem.title = @"示例报告";
    UIImageView *leftImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
    leftImageView.image = [UIImage imageNamed:@"houtui"];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftImageView];
    UITapGestureRecognizer *leftTapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(lastPage:)];
    [leftImageView addGestureRecognizer:leftTapGes];
    
}

#pragma mark - 返回上一页面
- (void)lastPage:(UITapGestureRecognizer *)tapGes
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - 检查网络并建立数据源
- (void)searchNetAndAddData
{
    if ([[[NetStatusHandle shareHandle] getNetStatus] isEqualToString:@"YES"]) {
        // 说明有网络
        // 建立数据源
        [self addData];
        // 建立计时器，计算是否超时
        self.myTimer = [NSTimer timerWithTimeInterval:1 target:self selector:@selector(goTimeOnShiLiBaoGaoGeXingTianFu:) userInfo:nil repeats:YES];
        [[NSRunLoop currentRunLoop] addTimer:self.myTimer forMode:NSRunLoopCommonModes];
        self.numberOfTime = 0;
        
        // 开始动画
        [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] startAnimation];
    } else {
        NSLog(@"没有网络");
        // 添加提示框
        [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] addAlertTitle:@"通知" Content:kNoNetNoRefresh ToView:self];
    }
}

#pragma mark - 计时器方法
- (void)goTimeOnShiLiBaoGaoGeXingTianFu:(NSTimer *)timer
{
    self.numberOfTime++;
    NSLog(@"示例报告天赋单项界面时间= %ld", self.numberOfTime);
    if (self.numberOfTime > kZGWQingQiuChaoShi) {
        NSLog(@"示例报告天赋单项界面请求超时");
        self.numberOfTime = 0;
        [self.myTimer invalidate];
        // 关闭动画
        [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] stopAnimation];
        // 添加提示框
        [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] addAlertTitle:@"通知" Content:kQingQiuChaoShiNoReFresh ToView:self];
    }
}

// 添加数据源
- (void)addData
{
    // 单项请求url
    NSString *danXiangUrl = [NSString stringWithFormat:@"%@", kZGWGetDetailDanXiangByName];
    NSDictionary *paramaterDic = @{@"name":self.zgwTianFuAndDaiXieModel.name};
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    [manager GET:danXiangUrl parameters:paramaterDic success:^(NSURLSessionDataTask *task, id responseObject) {
        self.numberOfTime = 0;
        [self.myTimer invalidate];
        // 关闭动画
        [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] stopAnimation];
        if (!responseObject) {
            return;
        }
        self.navigationItem.title = self.zgwTianFuAndDaiXieModel.name;
        NSDictionary *statusDic = [responseObject valueForKey:@"status"];
        NSString *codeString = [NSString stringWithFormat:@"%@", [statusDic valueForKey:@"code"]];
        if ([codeString isEqualToString:@"0"]) {
            NSDictionary *singleDic = [responseObject valueForKey:@"single"];
            // 疾病介绍
            self.diseaseIntroduceString = [singleDic valueForKey:@"summary"];
            
            
            // 构建基因表的数据
            NSArray *geneArray = self.zgwTianFuAndDaiXieModel.geneArray;
            self.jiYinBiaoGeArray = [NSMutableArray array];
            for (NSDictionary *tempDic in geneArray) {
                JiYinJianCeJieGuoModel *model = [[JiYinJianCeJieGuoModel alloc] init];
                [model setValuesForKeysWithDictionary:tempDic];
                [self.jiYinBiaoGeArray addObject:model];
            }
            // 保存表格详解笑脸位置
            self.xiaoLianRectArray = [NSMutableArray array];
            for (int i = 0; i < self.jiYinBiaoGeArray.count; i++) {
                
                CGFloat tempCount = 30  * kAdjustParamater + 38 * i * kAdjustParamater;
                [self.xiaoLianRectArray addObject:[NSNumber numberWithFloat:tempCount]];
            }
            
            // 染色体名字数组
            self.ranSeTiNameArray = [NSMutableArray array];
            for (NSDictionary *tempDic in geneArray) {
                // 构建染色体的url
                NSString *ranSeTiUrl = [NSString stringWithFormat:@"http://120.26.129.84/uploads/img/chr/png/chr%@_%@.png", [tempDic valueForKey:@"chrom"], [tempDic valueForKey:@"rs_pos"]];
                [self.ranSeTiNameArray addObject:ranSeTiUrl];
            }
            // 染色体位置
            self.ranSeTiImageWeiZhiArray = [NSMutableArray array];
            for (int i = 0; i < self.jiYinBiaoGeArray.count; i++) {
                //  [self.ranSeTiNameArray addObject:@"ranseti-shilibaogao"];
                CGFloat tempHeight = 25 * kAdjustParamater + 38 * i * kAdjustParamater;
                [self.ranSeTiImageWeiZhiArray addObject:[NSNumber numberWithFloat:tempHeight]];
            }
            
           
            // 健康建议
            NSArray *advanceArray = self.zgwTianFuAndDaiXieModel.advanceArray;
            self.jianKangJianYiArray = [NSMutableArray array];
            for (NSString *tempString in advanceArray) {
                [self.jianKangJianYiArray addObject:tempString];
            }
            // 图片
            self.imageUrl = [singleDic valueForKey:@"img_url"];
            
            // 局限性数组
            self.jvXianXingArray = [NSMutableArray arrayWithObjects:@"1、该检测无法覆盖所有与检测相关的结果。", @"2、基因只是影响性状的一部分因素，其他可能的因素包括环境和生活方式等。", @"3、该结果不能用于临床诊断。", @"4、该结果会随着参与人数的增多不断优化", nil];
            
            // 单项的标签
            self.danXiangBiaoQianArray = [NSMutableArray array];
            for (NSString *tempString in self.zgwTianFuAndDaiXieModel.advantage) {
                [self.danXiangBiaoQianArray addObject:tempString];
            }
            for (NSString *tempString in self.zgwTianFuAndDaiXieModel.notice) {
                [self.danXiangBiaoQianArray addObject:tempString];
            }

        } else {
            [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] addAlertNoTitieWithContent:@"单项数据获取失败，请返回重试" toView:self];
        }
        
        // 布局
        [self addMySubview];
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        // 关闭动画
        [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] stopAnimation];
        // 添加提示框
        [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] addAlertTitle:@"通知" Content:@"请求数据失败，请返回上一页后重新进入" ToView:self];
        // 暂停计时器
        [self.myTimer invalidate];
        self.numberOfTime = 0;
    }];

}

#pragma mark - 布局
- (void)addMySubview
{
    // 背景
    self.backGroundScrollview = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
    self.backGroundScrollview.backgroundColor = [UIColor whiteColor];
    self.backGroundScrollview.contentSize = CGSizeMake(kScreenWidth, 3 * kScreenHeight);
    self.backGroundScrollview.bounces = NO;
    self.backGroundScrollview.showsVerticalScrollIndicator = NO;
    [self.view addSubview:_backGroundScrollview];
    
    // 疾病介绍标题label
    UILabel *diseaseIntroduceTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0 * kAdjustParamater, 15 * kAdjustParamater, 375 * kAdjustParamater, 20 * kAdjustParamater)];
    // diseaseIntroduceTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
   
        diseaseIntroduceTitleLabel.text = [NSString stringWithFormat:@"%@介绍", self.zgwTianFuAndDaiXieModel.name];
    
    
    diseaseIntroduceTitleLabel.textColor = kCyanColor;
    diseaseIntroduceTitleLabel.textAlignment = NSTextAlignmentCenter;
    diseaseIntroduceTitleLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k20Big];
    [self.backGroundScrollview addSubview:diseaseIntroduceTitleLabel];
    
    // 计算疾病名字的长度
    CGFloat widthOfDieaseName = [[NetStatusHandle shareHandle] adjustWidth:diseaseIntroduceTitleLabel.text size:20 height:20];
    
    // 进入圈子
    UIImageView *joinQuanZiImageV = [[UIImageView alloc] initWithFrame:CGRectMake(290 * kAdjustParamater, 17 * kAdjustParamater, 15 * kAdjustParamater, 15 * kAdjustParamater)];
    joinQuanZiImageV.image = [UIImage imageNamed:@"三角图片"];
    [self.backGroundScrollview addSubview:joinQuanZiImageV];
    
    
    
    UIButton *joinQuanZiButton = [UIButton buttonWithType:UIButtonTypeSystem];
    joinQuanZiButton.frame = CGRectMake(joinQuanZiImageV.right, 17 * kAdjustParamater, 70 * kAdjustParamater, 15 * kAdjustParamater);
    [joinQuanZiButton setTitle:@"进入圈子" forState:UIControlStateNormal];
    [joinQuanZiButton setTitleColor:[[UIColor blackColor] colorWithAlphaComponent:0.5] forState:UIControlStateNormal];
    joinQuanZiButton.titleLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k15Big];
    [joinQuanZiButton addTarget:self action:@selector(joinQuanZiOnTianFu:) forControlEvents:UIControlEventTouchUpInside];
    [self.backGroundScrollview addSubview:joinQuanZiButton];
    
    // 疾病介绍下方灰色条
    UILabel *grayLineOnDiseaseIntroduceBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, diseaseIntroduceTitleLabel.bottom + 15 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
    grayLineOnDiseaseIntroduceBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
    [self.backGroundScrollview addSubview:grayLineOnDiseaseIntroduceBottom];
    
    // 疾病介绍下方灰色条上方的倩色条
    UILabel *cyanLineOnDiseaseIntroduceBottom = [[UILabel alloc] initWithFrame:CGRectMake((375 * kAdjustParamater - widthOfDieaseName - 20 * kAdjustParamater) / 2, diseaseIntroduceTitleLabel.bottom + 15 * kAdjustParamater, widthOfDieaseName + 20 * kAdjustParamater, 1 * kAdjustParamater)];
    cyanLineOnDiseaseIntroduceBottom.backgroundColor = kCyanColor;
    [self.backGroundScrollview addSubview:cyanLineOnDiseaseIntroduceBottom];
    
    
    
#warning 个性天赋或者代谢介绍
    // 疾病的图片
    UIImageView *jiBingImageV = [[UIImageView alloc] initWithFrame:CGRectMake(50 * kAdjustParamater, grayLineOnDiseaseIntroduceBottom.bottom + 23 * kAdjustParamater, 275 * kAdjustParamater, 178 * kAdjustParamater)];
    jiBingImageV.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    jiBingImageV.layer.cornerRadius = 5 * kAdjustParamater;
    [jiBingImageV sd_setImageWithURL:[NSURL URLWithString:self.imageUrl] placeholderImage:[UIImage imageNamed:@""]];
    jiBingImageV.layer.masksToBounds = YES;
    [self.backGroundScrollview addSubview:jiBingImageV];
    
    // 疾病介绍
    UILabel *diseaseIntroduceLabel = [[UILabel alloc] initWithFrame:CGRectMake(11 * kAdjustParamater, jiBingImageV.bottom + 20 * kAdjustParamater, (375 - 22) * kAdjustParamater, 50 * kAdjustParamater)];
    //  diseaseIntroduceLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    
    diseaseIntroduceLabel.text = self.diseaseIntroduceString;
    diseaseIntroduceLabel.textColor = [UIColor blackColor];
    diseaseIntroduceLabel.font = [UIFont systemFontOfSize:k15Big];
    diseaseIntroduceLabel.numberOfLines = 0;
    // 调整行间距
    [diseaseIntroduceLabel setAttributedText:[[NetStatusHandle shareHandle] setHangJianJvOfLabel:diseaseIntroduceLabel.text lineHeight:5]];
    [diseaseIntroduceLabel sizeToFit];
    [self.backGroundScrollview addSubview:diseaseIntroduceLabel];
    
    
    // 疾病介绍下方的灰色条
    UILabel *grayLineOnJiBingJieShaoBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, diseaseIntroduceLabel.bottom + 30 * kAdjustParamater, kScreenWidth, 10 * kAdjustParamater)];
    grayLineOnJiBingJieShaoBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.05];
    [self.backGroundScrollview addSubview:grayLineOnJiBingJieShaoBottom];
    
#warning   检测结果
    // 检测结果
    
    UILabel *whoJianCeJieGuoLabel = [[UILabel alloc] initWithFrame:CGRectMake(0 * kAdjustParamater, grayLineOnJiBingJieShaoBottom.bottom + 15 * kAdjustParamater, 375 * kAdjustParamater, 20 * kAdjustParamater)];
    // diseaseIntroduceTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    whoJianCeJieGuoLabel.text = [NSString stringWithFormat:@"%@的检测结果", self.userName];
    whoJianCeJieGuoLabel.textColor = kCyanColor;
    whoJianCeJieGuoLabel.textAlignment = NSTextAlignmentCenter;
    whoJianCeJieGuoLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k20Big];
    [self.backGroundScrollview addSubview:whoJianCeJieGuoLabel];
    
    // 计算检测结果的宽度
    CGFloat widthOfWhoJianCeJieGuoLabel = [[NetStatusHandle shareHandle] adjustWidth:whoJianCeJieGuoLabel.text size:20 height:20];
    
    // 检测结果下方灰色条
    UILabel *grayLineOnWhoJianCeJieGuoBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, whoJianCeJieGuoLabel.bottom + 15 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
    grayLineOnWhoJianCeJieGuoBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
    [self.backGroundScrollview addSubview:grayLineOnWhoJianCeJieGuoBottom];
    
    // 基因位点检测信息下方灰色条上方的倩色条
    UILabel *cyanLineOnWhoJianCeJieGuoBottom = [[UILabel alloc] initWithFrame:CGRectMake((375 * kAdjustParamater - widthOfWhoJianCeJieGuoLabel - 20 * kAdjustParamater) / 2, whoJianCeJieGuoLabel.bottom + 15 * kAdjustParamater, widthOfWhoJianCeJieGuoLabel + 20 * kAdjustParamater, 1 * kAdjustParamater)];
    cyanLineOnWhoJianCeJieGuoBottom.backgroundColor = kCyanColor;
    [self.backGroundScrollview addSubview:cyanLineOnWhoJianCeJieGuoBottom];
    
    // 五个圆圈
    
    // 弱的背景
    UILabel *ruoLabelBackGround = [[UILabel alloc] initWithFrame:CGRectMake(4 * kAdjustParamater,grayLineOnWhoJianCeJieGuoBottom.bottom + 17 * kAdjustParamater, 66 * kAdjustParamater, 66 * kAdjustParamater)];
    ruoLabelBackGround.backgroundColor = [kCyanColor colorWithAlphaComponent:0.4];
    ruoLabelBackGround.layer.cornerRadius = ruoLabelBackGround.width / 2;
    ruoLabelBackGround.layer.masksToBounds = YES;
    ruoLabelBackGround.hidden = YES;
    [self.backGroundScrollview addSubview:ruoLabelBackGround];
    // 弱
    UILabel *ruoLabel = [[UILabel alloc] initWithFrame:CGRectMake(12 * kAdjustParamater,grayLineOnWhoJianCeJieGuoBottom.bottom + 25 * kAdjustParamater, 50 * kAdjustParamater, 50 * kAdjustParamater)];
    ruoLabel.backgroundColor = [UIColor whiteColor];
    ruoLabel.text = @"弱";
    ruoLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k15Big];
    ruoLabel.textColor = kCyanColor;
    ruoLabel.textAlignment = NSTextAlignmentCenter;
    ruoLabel.layer.borderColor = kCyanColor.CGColor;
    ruoLabel.layer.borderWidth = 2 * kAdjustParamater;
    ruoLabel.layer.cornerRadius = ruoLabel.width / 2;
    ruoLabel.layer.masksToBounds = YES;
    [self.backGroundScrollview addSubview:ruoLabel];
    
    // 较弱的背景
    UILabel *jiaoRuoLabelBackGround = [[UILabel alloc] initWithFrame:CGRectMake(ruoLabelBackGround.right + 9 * kAdjustParamater,grayLineOnWhoJianCeJieGuoBottom.bottom + 17 * kAdjustParamater, 66 * kAdjustParamater, 66 * kAdjustParamater)];
    jiaoRuoLabelBackGround.backgroundColor = [kCyanColor colorWithAlphaComponent:0.4];
    jiaoRuoLabelBackGround.layer.cornerRadius = jiaoRuoLabelBackGround.width / 2;
    jiaoRuoLabelBackGround.layer.masksToBounds = YES;
    jiaoRuoLabelBackGround.hidden = YES;
    [self.backGroundScrollview addSubview:jiaoRuoLabelBackGround];
    
    // 较弱
    UILabel *jiaoRuoLabel = [[UILabel alloc] initWithFrame:CGRectMake(ruoLabel.right + 25 * kAdjustParamater, ruoLabel.top, 50 * kAdjustParamater, 50 * kAdjustParamater)];
    jiaoRuoLabel.backgroundColor = [UIColor whiteColor];
    jiaoRuoLabel.text = @"较弱";
    jiaoRuoLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k15Big];
    jiaoRuoLabel.textColor = kCyanColor;
    jiaoRuoLabel.textAlignment = NSTextAlignmentCenter;
    jiaoRuoLabel.layer.borderColor = kCyanColor.CGColor;
    jiaoRuoLabel.layer.borderWidth = 2 * kAdjustParamater;
    jiaoRuoLabel.layer.cornerRadius = jiaoRuoLabel.width / 2;
    jiaoRuoLabel.layer.masksToBounds = YES;
    [self.backGroundScrollview addSubview:jiaoRuoLabel];
    
    // 正常的背景
    UILabel *zhengChangLabelBackGround = [[UILabel alloc] initWithFrame:CGRectMake(jiaoRuoLabelBackGround.right + 9 * kAdjustParamater,grayLineOnWhoJianCeJieGuoBottom.bottom + 17 * kAdjustParamater, 66 * kAdjustParamater, 66 * kAdjustParamater)];
    zhengChangLabelBackGround.backgroundColor = [kCyanColor colorWithAlphaComponent:0.4];
    zhengChangLabelBackGround.layer.cornerRadius = zhengChangLabelBackGround.width / 2;
    zhengChangLabelBackGround.layer.masksToBounds = YES;
    zhengChangLabelBackGround.hidden = YES;
    [self.backGroundScrollview addSubview:zhengChangLabelBackGround];
    
    // 正常
    UILabel *zhengChangLabel = [[UILabel alloc] initWithFrame:CGRectMake(jiaoRuoLabel.right + 25 * kAdjustParamater, ruoLabel.top, 50 * kAdjustParamater, 50 * kAdjustParamater)];
    zhengChangLabel.backgroundColor = [UIColor whiteColor];
    zhengChangLabel.text = @"正常";
    zhengChangLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k15Big];
    zhengChangLabel.textColor = kCyanColor;
    zhengChangLabel.textAlignment = NSTextAlignmentCenter;
    zhengChangLabel.layer.borderColor = kCyanColor.CGColor;
    zhengChangLabel.layer.borderWidth = 2 * kAdjustParamater;
    zhengChangLabel.layer.cornerRadius = zhengChangLabel.width / 2;
    zhengChangLabel.layer.masksToBounds = YES;
    [self.backGroundScrollview addSubview:zhengChangLabel];
    
    // 较强的背景
    UILabel *jiaoQiangLabelBackGround = [[UILabel alloc] initWithFrame:CGRectMake(zhengChangLabelBackGround.right + 9 * kAdjustParamater,grayLineOnWhoJianCeJieGuoBottom.bottom + 17 * kAdjustParamater, 66 * kAdjustParamater, 66 * kAdjustParamater)];
    jiaoQiangLabelBackGround.backgroundColor = [kCyanColor colorWithAlphaComponent:0.4];
    jiaoQiangLabelBackGround.layer.cornerRadius = jiaoQiangLabelBackGround.width / 2;
    jiaoQiangLabelBackGround.layer.masksToBounds = YES;
    jiaoQiangLabelBackGround.hidden = YES;
    [self.backGroundScrollview addSubview:jiaoQiangLabelBackGround];
    
    // 较强
    UILabel *jiaoQiangLabel = [[UILabel alloc] initWithFrame:CGRectMake(zhengChangLabel.right + 25 * kAdjustParamater, ruoLabel.top, 50 * kAdjustParamater, 50 * kAdjustParamater)];
    jiaoQiangLabel.backgroundColor = [UIColor whiteColor];
    jiaoQiangLabel.text = @"较强";
    jiaoQiangLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k15Big];
    jiaoQiangLabel.textColor = kCyanColor;
    jiaoQiangLabel.textAlignment = NSTextAlignmentCenter;
    jiaoQiangLabel.layer.borderColor = kCyanColor.CGColor;
    jiaoQiangLabel.layer.borderWidth = 2 * kAdjustParamater;
    jiaoQiangLabel.layer.cornerRadius = jiaoQiangLabel.width / 2;
    jiaoQiangLabel.layer.masksToBounds = YES;
    [self.backGroundScrollview addSubview:jiaoQiangLabel];
    
    // 强的背景
    UILabel *QiangLabelBackGround = [[UILabel alloc] initWithFrame:CGRectMake(jiaoQiangLabelBackGround.right + 9 * kAdjustParamater,grayLineOnWhoJianCeJieGuoBottom.bottom + 17 * kAdjustParamater, 66 * kAdjustParamater, 66 * kAdjustParamater)];
    QiangLabelBackGround.backgroundColor = [kCyanColor colorWithAlphaComponent:0.4];
    QiangLabelBackGround.layer.cornerRadius = QiangLabelBackGround.width / 2;
    QiangLabelBackGround.layer.masksToBounds = YES;
    QiangLabelBackGround.hidden = YES;
    [self.backGroundScrollview addSubview:QiangLabelBackGround];
    
    // 强
    UILabel *QiangLabel = [[UILabel alloc] initWithFrame:CGRectMake(jiaoQiangLabel.right + 25 * kAdjustParamater, ruoLabel.top, 50 * kAdjustParamater, 50 * kAdjustParamater)];
    QiangLabel.backgroundColor = [UIColor whiteColor];
    QiangLabel.text = @"强";
    QiangLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k15Big];
    QiangLabel.textColor = kCyanColor;
    QiangLabel.textAlignment = NSTextAlignmentCenter;
    QiangLabel.layer.borderWidth = 2 * kAdjustParamater;
    QiangLabel.layer.cornerRadius = QiangLabel.width / 2;
    QiangLabel.layer.borderColor = kCyanColor.CGColor;
    QiangLabel.layer.masksToBounds = YES;
    [self.backGroundScrollview addSubview:QiangLabel];
    
    // 判断风险等级
    NSString *fengXianLevel = self.zgwTianFuAndDaiXieModel.risk_level;
    NSString *pingJiangString = @"";
    if ([fengXianLevel isEqualToString:@"0"]) {
        // 弱
        ruoLabel.backgroundColor = [kCyanColor colorWithAlphaComponent:0.9];
        ruoLabel.textColor = [UIColor whiteColor];
        ruoLabelBackGround.hidden = NO;
        pingJiangString = @"弱";
    } else if ([fengXianLevel isEqualToString:@"1"]) {
        // 较弱
        jiaoRuoLabel.backgroundColor = [kCyanColor colorWithAlphaComponent:0.9];
        jiaoRuoLabel.textColor = [UIColor whiteColor];
        jiaoRuoLabelBackGround.hidden = NO;
        pingJiangString = @"较弱";
    } else if ([fengXianLevel isEqualToString:@"2"]) {
        // 正常
        zhengChangLabel.backgroundColor = [kCyanColor colorWithAlphaComponent:0.9];
        zhengChangLabel.textColor = [UIColor whiteColor];
        zhengChangLabelBackGround.hidden = NO;
        pingJiangString = @"正常";
    } else if ([fengXianLevel isEqualToString:@"3"]) {
        // 较强
        jiaoQiangLabel.backgroundColor = [kCyanColor colorWithAlphaComponent:0.9];
        jiaoQiangLabel.textColor = [UIColor whiteColor];
        jiaoQiangLabelBackGround.hidden = NO;
        pingJiangString = @"较强";
    } else if ([fengXianLevel isEqualToString:@"4"]) {
        // 强
        QiangLabel.backgroundColor = [kCyanColor colorWithAlphaComponent:0.9];
        QiangLabel.textColor = [UIColor whiteColor];
        QiangLabelBackGround.hidden = NO;
        pingJiangString = @"强";
    }
    UILabel *huanBingJiLvLevelLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, ruoLabel.bottom + 25 * kAdjustParamater, kScreenWidth, 15 * kAdjustParamater)];
    huanBingJiLvLevelLabel.text = [NSString stringWithFormat:@"您的%@%@", self.zgwTianFuAndDaiXieModel.name, pingJiangString];
    huanBingJiLvLevelLabel.textAlignment = NSTextAlignmentCenter;
    huanBingJiLvLevelLabel.textColor = [UIColor colorWithRed:243 / 255.0 green:151 / 255.0 blue:0 alpha:1];
    huanBingJiLvLevelLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k15Big];
    [self.backGroundScrollview addSubview:huanBingJiLvLevelLabel];
    
    // 进行单项标签的布局
    // 记录左边开始位置
    CGFloat leftPoint = 0.0;
    // 记录其实的高度
    CGFloat heightPoint = 0.0;
    // 记录换了几次行
    NSInteger huanHangCount = 0;
    for (int i = 0; i < self.danXiangBiaoQianArray.count; i++) {
        CGFloat tempWidth = [[NetStatusHandle shareHandle] adjustWidth:self.danXiangBiaoQianArray[i] size:16 height:30];
        if ((leftPoint + tempWidth) > 329 * kAdjustParamater) {
            // 说明需要换行,这时需要重置左起位置
            leftPoint = 0.0;
            huanHangCount++;
            //  NSLog(@"huanHangCount = %ld", huanHangCount);
            heightPoint = (25 + 10) * kAdjustParamater * huanHangCount;
        }
        //  NSLog(@"heightPoint = %f", heightPoint);
        UILabel *tempLabel = [[UILabel alloc] initWithFrame:CGRectMake(23 * kAdjustParamater + leftPoint, huanBingJiLvLevelLabel.bottom + 20 * kAdjustParamater + heightPoint, 50 * kAdjustParamater, 25 * kAdjustParamater)];
        tempLabel.text = self.danXiangBiaoQianArray[i];
        tempLabel.backgroundColor = [UIColor whiteColor];
        tempLabel.textColor = [UIColor colorWithRed:82 / 255.0 green:199 / 255.0 blue:220 / 255.0 alpha:1];
        tempLabel.tag = 200 + i;
        tempLabel.textAlignment = NSTextAlignmentCenter;
        tempLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k15Big];
        tempLabel.layer.cornerRadius = 10 * kAdjustParamater;
        tempLabel.layer.masksToBounds = YES;
        tempLabel.layer.borderColor = [[UIColor colorWithRed:72 / 255.0 green:170 / 255.0 blue:204 / 255.0 alpha:1] CGColor];
        tempLabel.layer.borderWidth = 1 * kAdjustParamater;
        
        
        // 进行自适应宽度
        CGRect newFrame = tempLabel.frame;
        newFrame.size.width = [[NetStatusHandle shareHandle] adjustWidth:tempLabel.text size:15 height:25] + 16 * kAdjustParamater;
        tempLabel.frame = newFrame;
        
        // 保存下一个label的左起位置
        leftPoint = tempLabel.frame.size.width + 13 * kAdjustParamater + leftPoint;
        //    NSLog(@"左起为止:%f", leftPoint);
        [self.backGroundScrollview addSubview:tempLabel];
        
    }
    
    // 取出最后一个label
    UILabel *lastLabelOfBiaoQian = (UILabel *)[self.view viewWithTag:199 + self.danXiangBiaoQianArray.count];
    
    

    
    // 检测结果下方的灰色条
    UILabel *grayLineOnJianCeJieGuoBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, lastLabelOfBiaoQian.bottom + 25 * kAdjustParamater, kScreenWidth, 10 * kAdjustParamater)];
    grayLineOnJianCeJieGuoBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.05];
    [self.backGroundScrollview addSubview:grayLineOnJianCeJieGuoBottom];
#pragma mark - 基因位点检测信息
    // 基因位点检测信息
    UILabel *jianCeJieGuoLabel = [[UILabel alloc] initWithFrame:CGRectMake(0 * kAdjustParamater, grayLineOnJianCeJieGuoBottom.bottom + 15 * kAdjustParamater, 375 * kAdjustParamater, 20 * kAdjustParamater)];
    // diseaseIntroduceTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    jianCeJieGuoLabel.text = @"基因位点检测信息";
    jianCeJieGuoLabel.textColor = kCyanColor;
    jianCeJieGuoLabel.textAlignment = NSTextAlignmentCenter;
    jianCeJieGuoLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k20Big];
    [self.backGroundScrollview addSubview:jianCeJieGuoLabel];
    
    // 基因位点检测信息下方灰色条
    UILabel *grayLineOnJianCeJieGuoBottom2 = [[UILabel alloc] initWithFrame:CGRectMake(0, jianCeJieGuoLabel.bottom + 15 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
    grayLineOnJianCeJieGuoBottom2.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
    [self.backGroundScrollview addSubview:grayLineOnJianCeJieGuoBottom2];
    
    // 基因位点检测信息下方灰色条上方的倩色条
    UILabel *cyanLineOnJianCeJieGuoBottom = [[UILabel alloc] initWithFrame:CGRectMake((375 - 170) / 2 * kAdjustParamater, jianCeJieGuoLabel.bottom + 15 * kAdjustParamater, 170 * kAdjustParamater, 1 * kAdjustParamater)];
    cyanLineOnJianCeJieGuoBottom.backgroundColor = kCyanColor;
    [self.backGroundScrollview addSubview:cyanLineOnJianCeJieGuoBottom];
#warning 基因表
    self.jiYinBiaoGe = [[KWFormView alloc] initWithFrame:CGRectMake(7  *kAdjustParamater,  cyanLineOnJianCeJieGuoBottom.bottom + 20 * kAdjustParamater, 360 * kAdjustParamater, (22 + 38 * self.jiYinBiaoGeArray.count) * kAdjustParamater)];
    self.jiYinBiaoGe.dataSource = self;
    self.jiYinBiaoGe.delegate = self;
    self.jiYinBiaoGe.tag = 300;
    [self.backGroundScrollview addSubview:_jiYinBiaoGe];
    
    
    for (int i = 0; i < self.jiYinBiaoGeArray.count; i++) {
        JiYinJianCeJieGuoModel *tempModel = self.jiYinBiaoGeArray[i];
        NSString *influenceString = tempModel.influence;
        // 位置
        CGFloat heightWeiZhi = [self.xiaoLianRectArray[i] floatValue];
        UIImageView *tempImageV = [[UIImageView alloc] initWithFrame:CGRectMake(230 * kAdjustParamater, heightWeiZhi * kAdjustParamater, 25 * kAdjustParamater, 25 * kAdjustParamater)];
        //   tempImageV.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
        // 0代表抑制、1代表稍微抑制、2代表正常、3代表稍微促进、4代表促进
        if ([influenceString isEqualToString:@"0"]) {
            tempImageV.image = [UIImage imageNamed:@"yukuai-shillibaogao"];
        } else if ([influenceString isEqualToString:@"1"]) {
            tempImageV.image = [UIImage imageNamed:@"shaoweiyukuai-shilibaogao"];
        } else if ([influenceString isEqualToString:@"2"]) {
            tempImageV.image = [UIImage imageNamed:@"zhengchang-shilibaogao"];
        } else if ([influenceString isEqualToString:@"3"]) {
            tempImageV.image = [UIImage imageNamed:@"shaoweibugaoxing-shilibaogao"];
        } else if ([influenceString isEqualToString:@"4"]) {
            tempImageV.image = [UIImage imageNamed:@"bugaoxing-shilibaogao"];
        }
        [_jiYinBiaoGe addSubview:tempImageV];
    }
    
    // 表格详解
    UIButton *biaoGeXiangJieButton = [UIButton buttonWithType:UIButtonTypeSystem];
    biaoGeXiangJieButton.frame = CGRectMake(95 / 2 * kAdjustParamater,self.jiYinBiaoGe.bottom + 30 * kAdjustParamater, 115 * kAdjustParamater, 30 * kAdjustParamater);
    biaoGeXiangJieButton.backgroundColor = kCyanColor;
    [biaoGeXiangJieButton setTitle:@"表格详解" forState:UIControlStateNormal];
    [biaoGeXiangJieButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    biaoGeXiangJieButton.layer.cornerRadius = 5 * kAdjustParamater;
    biaoGeXiangJieButton.titleLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k18Big];
    [biaoGeXiangJieButton addTarget:self action:@selector(biaoGeXiangJie:) forControlEvents:UIControlEventTouchUpInside];
    [self.backGroundScrollview addSubview:biaoGeXiangJieButton];
    
    // 参考文献
    UIButton *canKaoWenXianButton = [UIButton buttonWithType:UIButtonTypeSystem];
    canKaoWenXianButton.frame = CGRectMake(biaoGeXiangJieButton.right + 50 * kAdjustParamater, biaoGeXiangJieButton.top, 115 * kAdjustParamater, 30 * kAdjustParamater);
    canKaoWenXianButton.backgroundColor = kCyanColor;
    [canKaoWenXianButton setTitle:@"参考文献" forState:UIControlStateNormal];
    [canKaoWenXianButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    canKaoWenXianButton.layer.cornerRadius = 5 * kAdjustParamater;
    canKaoWenXianButton.titleLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k18Big];
    [canKaoWenXianButton addTarget:self action:@selector(canKaoWenXian:) forControlEvents:UIControlEventTouchUpInside];
    [self.backGroundScrollview addSubview:canKaoWenXianButton];
    
    // 表格详解下方的灰色条
    UILabel *grayLineOnBiaoGeXiangJieBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, biaoGeXiangJieButton.bottom + 20 * kAdjustParamater, kScreenWidth, 10 * kAdjustParamater)];
    grayLineOnBiaoGeXiangJieBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.05];
    [self.backGroundScrollview addSubview:grayLineOnBiaoGeXiangJieBottom];
    
    // 基因位置标题label
    UILabel *jiYinWeiZhiLabel = [[UILabel alloc] initWithFrame:CGRectMake(0 * kAdjustParamater,grayLineOnBiaoGeXiangJieBottom.bottom + 15 * kAdjustParamater, 375 * kAdjustParamater, 20 * kAdjustParamater)];
    // diseaseIntroduceTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    jiYinWeiZhiLabel.text = @"基因位置";
    jiYinWeiZhiLabel.textColor = kCyanColor;
    jiYinWeiZhiLabel.textAlignment = NSTextAlignmentCenter;
    jiYinWeiZhiLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k20Big];
    [self.backGroundScrollview addSubview:jiYinWeiZhiLabel];
    
    // 基因位置下方灰色条
    UILabel *grayLineOnJiYinWeiZhiBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, jiYinWeiZhiLabel.bottom + 15 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
    grayLineOnJiYinWeiZhiBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
    [self.backGroundScrollview addSubview:grayLineOnJiYinWeiZhiBottom];
    
    // 基因位置下方灰色条上方的倩色条
    UILabel *cyanLineOnJiYinWeiZhiBottom = [[UILabel alloc] initWithFrame:CGRectMake(275 / 2 * kAdjustParamater, jiYinWeiZhiLabel.bottom + 15 * kAdjustParamater, 100 * kAdjustParamater, 1 * kAdjustParamater)];
    cyanLineOnJiYinWeiZhiBottom.backgroundColor = kCyanColor;
    [self.backGroundScrollview addSubview:cyanLineOnJiYinWeiZhiBottom];
    
#warning 染色体信息
    // 染色体信息背景
    UIView *ranSeTiBackGroundView = [[UIView alloc] initWithFrame:CGRectMake(10 * kAdjustParamater, grayLineOnJiYinWeiZhiBottom.bottom + 20 * kAdjustParamater, 355 * kAdjustParamater, 170 * kAdjustParamater)];
    ranSeTiBackGroundView.backgroundColor = kCyanColor;
    [self.backGroundScrollview addSubview:ranSeTiBackGroundView];
    
    // 染色体信息标题
    UILabel *ranSeTiTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(255 / 2 * kAdjustParamater, 5 * kAdjustParamater, 100 * kAdjustParamater, 17 * kAdjustParamater)];
    //   ranSeTiTitleLabel.backgroundColor = [[UIColor redColor] colorWithAlphaComponent:0.1];
    ranSeTiTitleLabel.text = @"染色体信息";
    ranSeTiTitleLabel.textColor = [UIColor whiteColor];
    ranSeTiTitleLabel.textAlignment = NSTextAlignmentCenter;
    ranSeTiTitleLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k17Big];
    [ranSeTiBackGroundView addSubview:ranSeTiTitleLabel];
    
    // 染色体表格
    self.ranSeTiBiaoGe = [[KWFormView alloc] initWithFrame:CGRectMake(10 * kAdjustParamater, 27 * kAdjustParamater, 335 * kAdjustParamater, (22 + 38 * self.jiYinBiaoGeArray.count) * kAdjustParamater)];
    self.ranSeTiBiaoGe.dataSource = self;
    self.ranSeTiBiaoGe.delegate = self;
    self.ranSeTiBiaoGe.tag = 301;
    [ranSeTiBackGroundView addSubview:_ranSeTiBiaoGe];
    // 重新布局染色体背景的大小
    ranSeTiBackGroundView.frame = CGRectMake(ranSeTiBackGroundView.frame.origin.x, ranSeTiBackGroundView.frame.origin.y, ranSeTiBackGroundView.width, self.ranSeTiBiaoGe.height + 37 * kAdjustParamater);
    // 添加染色体图片
    for (int i = 0; i < self.ranSeTiImageWeiZhiArray.count; i++) {
        CGFloat ranSeTiHeight= [self.ranSeTiImageWeiZhiArray[i] floatValue];
        UIImageView *ranSeTiImageV = [[UIImageView alloc] initWithFrame:CGRectMake(145 * kAdjustParamater, ranSeTiHeight, 180 * kAdjustParamater, 33 * kAdjustParamater)];
        if (self.ranSeTiNameArray.count > i) {
            [ranSeTiImageV sd_setImageWithURL:[NSURL URLWithString:self.ranSeTiNameArray[i]] placeholderImage:[UIImage imageNamed:@""]];
        }
        [self.ranSeTiBiaoGe addSubview:ranSeTiImageV];
    }
    
    // 染色体表格下方的灰色条
    UILabel *grayLineOnRanSeTiBiaoGeBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, ranSeTiBackGroundView.bottom + 20 * kAdjustParamater, kScreenWidth, 10 * kAdjustParamater)];
    grayLineOnRanSeTiBiaoGeBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.05];
    [self.backGroundScrollview addSubview:grayLineOnRanSeTiBiaoGeBottom];
    
#warning 健康建议
    // 健康建议
    UILabel *jianKangJianYiLabel = [[UILabel alloc] initWithFrame:CGRectMake(0 * kAdjustParamater, grayLineOnRanSeTiBiaoGeBottom.bottom + 15 * kAdjustParamater, 375 * kAdjustParamater, 20 * kAdjustParamater)];
    // diseaseIntroduceTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    jianKangJianYiLabel.text = @"健康建议";
    jianKangJianYiLabel.textColor = kCyanColor;
    jianKangJianYiLabel.textAlignment = NSTextAlignmentCenter;
    jianKangJianYiLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k20Big];
    [self.backGroundScrollview addSubview:jianKangJianYiLabel];
    
    // 健康建议下方灰色条
    UILabel *grayLineOnjianKangJianYiBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, jianKangJianYiLabel.bottom + 15 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
    grayLineOnjianKangJianYiBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
    [self.backGroundScrollview addSubview:grayLineOnjianKangJianYiBottom];
    
    // 健康建议下方灰色条上方的倩色条
    UILabel *cyanLineOnjianKangJianYiBottom = [[UILabel alloc] initWithFrame:CGRectMake(275 / 2 * kAdjustParamater, jianKangJianYiLabel.bottom + 15 * kAdjustParamater, 100 * kAdjustParamater, 1 * kAdjustParamater)];
    cyanLineOnjianKangJianYiBottom.backgroundColor = kCyanColor;
    [self.backGroundScrollview addSubview:cyanLineOnjianKangJianYiBottom];
    
    //    // 健康建议的背景
    //    UIView *jianKangJianYiBackgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, warningTitleLabel.bottom + 15 * kAdjustParamater, kScreenWidth, 28 * kAdjustParamater)];
    //    jianKangJianYiBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.05];
    //    [self.backGroundScrollview addSubview:jianKangJianYiBackgroundView];
    //
    //    // 健康建议标题
    //    UILabel *jianKangJianTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake((375 - 150) / 2 * kAdjustParamater, 5 * kAdjustParamater, 150 * kAdjustParamater, 18 * kAdjustParamater)];
    //    jianKangJianTitleLabel.text = @"健康建议";
    //    jianKangJianTitleLabel.textColor = kCyanColor;
    //    jianKangJianTitleLabel.textAlignment = NSTextAlignmentCenter;
    //    jianKangJianTitleLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k17Big];
    //    [jianKangJianYiBackgroundView addSubview:jianKangJianTitleLabel];
    
    // 进行健康建议的动态布局
    // 保存健康建议下一个开始位置
    CGFloat jianKangJianYiNextHeight = 0.0;
    for (int i = 0; i < self.jianKangJianYiArray.count; i++) {
        // 健康建议前方图标
        UILabel *jianKangJianYiImageV = [[UILabel alloc] initWithFrame:CGRectMake(18 * kAdjustParamater, grayLineOnjianKangJianYiBottom.bottom + 13 * kAdjustParamater + jianKangJianYiNextHeight, 42 * kAdjustParamater, 20 * kAdjustParamater)];
        jianKangJianYiImageV.backgroundColor = kCyanColor;
        jianKangJianYiImageV.text = [NSString stringWithFormat:@"NO.%d", i + 1];
        jianKangJianYiImageV.textColor = [UIColor whiteColor];
        jianKangJianYiImageV.textAlignment = NSTextAlignmentCenter;
        jianKangJianYiImageV.font = [UIFont fontWithName:@"Arial-BoldMT" size:k14Big];
        jianKangJianYiImageV.layer.cornerRadius = 5 * kAdjustParamater;
        jianKangJianYiImageV.layer.masksToBounds = YES;
        [self.backGroundScrollview addSubview:jianKangJianYiImageV];
        
        // 健康建议内容
        UILabel *jianKangJianYiContentLabel = [[UILabel alloc] initWithFrame:CGRectMake(jianKangJianYiImageV.right + 15 * kAdjustParamater, jianKangJianYiImageV.top + 1 * kAdjustParamater, 285 * kAdjustParamater, 10 * kAdjustParamater)];
        //    jianKangJianYiContentLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
        jianKangJianYiContentLabel.text = self.jianKangJianYiArray[i];
        jianKangJianYiContentLabel.textColor = [UIColor blackColor];
        jianKangJianYiContentLabel.numberOfLines = 0;
        jianKangJianYiContentLabel.font = [UIFont systemFontOfSize:k14Big];
        // 调整高度
        CGRect jianKangJianYiNewFrame = jianKangJianYiContentLabel.frame;
        jianKangJianYiNewFrame.size.height = [[NetStatusHandle shareHandle] adjustHeight:jianKangJianYiContentLabel.text size:14 width:285];
        jianKangJianYiContentLabel.frame = jianKangJianYiNewFrame;
        [self.backGroundScrollview addSubview:jianKangJianYiContentLabel];
        
        // 添加灰色条
        UILabel *grayLineOnJianKangJianYiContentBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, jianKangJianYiContentLabel.bottom + 15 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
        grayLineOnJianKangJianYiContentBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.08];
        grayLineOnJianKangJianYiContentBottom.tag = 600 + i;
        [self.backGroundScrollview addSubview:grayLineOnJianKangJianYiContentBottom];
        jianKangJianYiNextHeight = jianKangJianYiNextHeight + jianKangJianYiContentLabel.height + 16 * kAdjustParamater + 13 * kAdjustParamater;
        
    }
    // 取出健康建议最后一个灰色条
    UILabel *lastGrayLineOfJianKangJianYi = (UILabel *)[self.view viewWithTag:599 + self.jianKangJianYiArray.count];

    
    UILabel *grayLineOnJianKangJianYiBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, lastGrayLineOfJianKangJianYi.bottom + 10 * kAdjustParamater, kScreenWidth, 10 * kAdjustParamater)];
    grayLineOnJianKangJianYiBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.05];
    [self.backGroundScrollview addSubview:grayLineOnJianKangJianYiBottom];
    
#warning 基因检测的局限性
    // 基因检测的局限性
    UILabel *jvXianXingLabel = [[UILabel alloc] initWithFrame:CGRectMake(0 * kAdjustParamater, grayLineOnJianKangJianYiBottom.bottom + 15 * kAdjustParamater, 375 * kAdjustParamater, 20 * kAdjustParamater)];
    // diseaseIntroduceTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    jvXianXingLabel.text = @"基因检测的局限性";
    jvXianXingLabel.textColor = kCyanColor;
    jvXianXingLabel.textAlignment = NSTextAlignmentCenter;
    jvXianXingLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k20Big];
    [self.backGroundScrollview addSubview:jvXianXingLabel];
    
    // 基因检测的局限性下方灰色条
    UILabel *grayLineOnjvXianXingBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, jvXianXingLabel.bottom + 15 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
    grayLineOnjvXianXingBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
    [self.backGroundScrollview addSubview:grayLineOnjvXianXingBottom];
    
    // 基因检测的局限性下方灰色条上方的倩色条
    UILabel *cyanLineOnjvXianXingBottom = [[UILabel alloc] initWithFrame:CGRectMake((375 - 170) / 2 * kAdjustParamater, jvXianXingLabel.bottom + 15 * kAdjustParamater, 170 * kAdjustParamater, 1 * kAdjustParamater)];
    cyanLineOnjvXianXingBottom.backgroundColor = kCyanColor;
    [self.backGroundScrollview addSubview:cyanLineOnjvXianXingBottom];

    
// 基因检测局限性的动态布局
    // 几率下一个局限性的开始位置
    CGFloat nextJvXianXingStringStart = 0.0;
    for (int i = 0; i < self.jvXianXingArray.count; i++) {
        // 前方的圆形
        UILabel *circleLabel = [[UILabel alloc] initWithFrame:CGRectMake(15 * kAdjustParamater, grayLineOnjvXianXingBottom.bottom + 20 * kAdjustParamater + nextJvXianXingStringStart, 15 * kAdjustParamater, 15 * kAdjustParamater)];
        circleLabel.backgroundColor = kCyanColor;
        circleLabel.layer.cornerRadius = circleLabel.width / 2;
        circleLabel.layer.masksToBounds = YES;
        [self.backGroundScrollview addSubview:circleLabel];
        
        // 局限性内容
        UILabel *jvXianXingStringLabel = [[UILabel alloc] initWithFrame:CGRectMake(circleLabel.right + 5 * kAdjustParamater, circleLabel.top, 325 * kAdjustParamater, 15 * kAdjustParamater)];
    //    jvXianXingStringLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
        jvXianXingStringLabel.text = self.jvXianXingArray[i];
        jvXianXingStringLabel.textColor = [[UIColor blackColor] colorWithAlphaComponent:0.7];
        jvXianXingStringLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k14Big];
        jvXianXingStringLabel.numberOfLines = 0;
        jvXianXingStringLabel.tag = 700 + i;
        // 调整行间距
        [jvXianXingStringLabel setAttributedText:[[NetStatusHandle shareHandle] setHangJianJvOfLabel:jvXianXingStringLabel.text lineHeight:4]];
        [jvXianXingStringLabel sizeToFit];
        [self.backGroundScrollview addSubview:jvXianXingStringLabel];
        
        nextJvXianXingStringStart = nextJvXianXingStringStart + jvXianXingStringLabel.height + 15 * kAdjustParamater;
        
    }
    
    // 取出最后一个局限性string
    UILabel *lastJvXianXingStringLabel = (UILabel *)[self.view viewWithTag:699 + self.jvXianXingArray.count];
    
    // 进入圈子
    UIImageView *FAQImageV = [[UIImageView alloc] initWithFrame:CGRectMake(290 * kAdjustParamater, lastJvXianXingStringLabel.bottom + 20 * kAdjustParamater, 15 * kAdjustParamater, 15 * kAdjustParamater)];
    FAQImageV.image = [UIImage imageNamed:@"三角图片"];
    [self.backGroundScrollview addSubview:FAQImageV];
    
    
    
    UIButton *FAQButton = [UIButton buttonWithType:UIButtonTypeSystem];
    FAQButton.frame = CGRectMake(FAQImageV.right, FAQImageV.top, 70 * kAdjustParamater, 15 * kAdjustParamater);
    [FAQButton setTitle:@"常见问题" forState:UIControlStateNormal];
    [FAQButton setTitleColor:[[UIColor blackColor] colorWithAlphaComponent:0.5] forState:UIControlStateNormal];
    FAQButton.titleLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:k15Big];
    [FAQButton addTarget:self action:@selector(FAQButton:) forControlEvents:UIControlEventTouchUpInside];
    [self.backGroundScrollview addSubview:FAQButton];

    
    
    // 调整background的内容大小
        self.backGroundScrollview.contentSize = CGSizeMake(kScreenWidth, lastJvXianXingStringLabel.bottom + 130 * kAdjustParamater);
    
    
    

    
}

#pragma mark - 表格的代理
- (NSInteger)numberOfRowsInFormView:(KWFormView *)formView
{
    if (formView.tag == 300) {
        return 1 + self.jiYinBiaoGeArray.count;
    } else if (formView.tag == 301) {
        return 1 + self.jiYinBiaoGeArray.count;
    }
    return 0;
}

- (NSInteger)formViewColumnsInRow:(KWFormView *)formView
{
    if (formView.tag == 300) {
        return 7;
    } else if (formView.tag == 301) {
        return 3;
    }
    return 0;
}

- (CGFloat)formView:(KWFormView *)formView widthForColumn:(NSInteger)column
{
    if (formView.tag == 300) {
        if (column == 0) {
            return 58 * kAdjustParamater;
        } else if (column == 1) {
            return 65 * kAdjustParamater;
        } else if (column == 2) {
            return 46 * kAdjustParamater;
        } else if (column == 3) {
            return 59 * kAdjustParamater;
        } else if (column == 4) {
            return 28 * kAdjustParamater;
        } else if (column == 5) {
            return 43 * kAdjustParamater;
        } else if (column == 6) {
            return 66 * kAdjustParamater;
        }
        
    } else if (formView.tag == 301) {
        if (column == 0) {
            return 70 * kAdjustParamater;
        } else if (column == 1) {
            return 70 * kAdjustParamater;
        } else if (column == 2) {
            return 195 * kAdjustParamater;
        }
    }
    return 0;
}

- (NSString *)formView:(KWFormView *)formView textForColumn:(NSInteger)column inRow:(NSInteger)row
{
    if (formView.tag == 300) {
        if (row == 0) {
            if (column == 0) {
                return @"基因";
            } else if (column == 1) {
                return @"检测位点";
            } else if (column == 2) {
                return @"基因型";
            } else if (column == 3) {
                return @"基因型概率";
            } else if (column == 4) {
                return @"评价";
            } else if (column == 5) {
                return @"影响";
            } else if (column == 6) {
                return @"参考文献数量";
            }
        } else {
            // 获得model
            if (self.jiYinBiaoGeArray.count > (row - 1)) {
                JiYinJianCeJieGuoModel *tempModel = self.jiYinBiaoGeArray[row - 1];
                if (column == 4) {
                    
                } else if (column == 0) {
                    // 基因名字
                    return tempModel.name;
                } else if (column == 1) {
                    // 检测位点
                    return tempModel.rs_id;
                } else if (column == 2) {
                    // 基因型
                    return tempModel.gene_type;
                } else if (column == 3) {
                    // 基因型概率
                    return tempModel.gene_probility;
                } else if (column == 5) {
                    // 影响
                    NSString *influenceString = @"";
                    if ([tempModel.influence isEqualToString:@"0"]) {
                        influenceString = @"抑制";
                    } else if ([tempModel.influence isEqualToString:@"1"]) {
                        influenceString = @"轻微抑制";
                    } else if ([tempModel.influence isEqualToString:@"2"]) {
                        influenceString = @"正常";
                    } else if ([tempModel.influence isEqualToString:@"3"]) {
                        influenceString = @"轻微促进";
                    } else if ([tempModel.influence isEqualToString:@"4"]) {
                        influenceString = @"促进";
                    }
                    return influenceString;
                } else if (column == 6) {
                    // 参考文献的数量
                    return [NSString stringWithFormat:@"%@个", tempModel.literature_count];
                    
                    
                }
            }
            
        }
    } else if (formView.tag == 301) {
        if (row == 0) {
            if (column == 0) {
                return @"检测位点";
            } else if (column == 1) {
                return @"染色体位置";
            } else if (column == 2) {
                return @"染色体图";
            }
        } else {
            if (self.jiYinBiaoGeArray.count > (row - 1)) {
                // 获得model
                JiYinJianCeJieGuoModel *tempModel = self.jiYinBiaoGeArray[row - 1];
                if (column == 0) {
                    // 检测位点
                    return tempModel.rs_id;
                }
                if (column == 1) {
                    // 染色体位置
                    return tempModel.location;
                }
            }
            
        }
    }
    
    return nil;
}

// 添加点击事件
- (BOOL)formView:(KWFormView *)formView addActionForColumn:(NSInteger)column inRow:(NSInteger)row
{
    if (formView.tag == 300) {
        return YES;
    }
    return NO;
}

- (void)formView:(KWFormView *)formView didSelectColumn:(NSInteger)column inRow:(NSInteger)row
{
//    if (column == 6) {
//        // 从1开始的，因此要减一
//        NSLog(@"点击了第%ld行", row - 1);
//        if (self.isShiLiBaoGao == YES) {
//            WenXianCanKaoListViewController *wenXianCanKaoListVC = [[WenXianCanKaoListViewController alloc] init];
//            wenXianCanKaoListVC.isShiLiBaoGao = YES;
//            if ((row - 1) == 0) {
//                wenXianCanKaoListVC.wenXianArray = [NSMutableArray arrayWithObjects:@"Lu X, Wang L, Chen S, et al. Genome-wide association study in Han Chinese identifies four new susceptibility loci for coronary artery disease.[J]. Nature Genetics, 2012, 44(8):890-4.", nil];
//            } else if ((row - 1) == 1) {
//                wenXianCanKaoListVC.wenXianArray = [NSMutableArray arrayWithObjects:@"Hinohara K, Nakajima T, Takahashi M, et al. Replication of the association between a chromosome 9p21 polymorphism and coronary artery disease in Japanese and Korean populations[J]. Journal of Human Genetics, 2008, 53(4):357-9.", nil];
//            } else if ((row - 1) == 2) {
//                wenXianCanKaoListVC.wenXianArray = [NSMutableArray arrayWithObjects:@"Willer C J, Sanna S, Jackson A U, et al. Newly identified loci that influence lipid concentrations and risk of coronary artery disease.[J]. Nature Genetics, 2008, 40(2):161-9.", nil];
//            } else if ((row - 1) == 3) {
//                wenXianCanKaoListVC.wenXianArray = [NSMutableArray arrayWithObjects:@"Schunkert H, König I R, Kathiresan S, et al. Large-scale association analysis identifies 13 new susceptibility loci for coronary artery disease[J]. Nature Genetics, 2011, 43(4):333-338.", nil];
//            } else if ((row - 1) == 4) {
//                wenXianCanKaoListVC.wenXianArray = [NSMutableArray arrayWithObjects:@"Gu Y, Liu Z, Li L, et al. OLR1, PON1 and MTHFR gene polymorphisms, conventional risk factors and the severity of coronary atherosclerosis in a Chinese Han population.[J]. Cellular Physiology & Biochemistry, 2013, 31(1):143-152.", nil];
//            } else if ((row - 1) == 5) {
//                wenXianCanKaoListVC.wenXianArray = [NSMutableArray arrayWithObjects:@"Lu X, Wang L, Chen S, et al. Genome-wide association study in Han Chinese identifies four new susceptibility loci for coronary artery disease.[J]. Nature Genetics, 2012, 44(8):890-4.", nil];
//            } else if ((row - 1) == 6) {
//                wenXianCanKaoListVC.wenXianArray = [NSMutableArray arrayWithObjects:@"an Wang, et al. Genome-wide association identifies a susceptibility locus for coronary artery disease in the Chinese Han population.Nature Genetics, doi:10.1038/ng.783.", nil];
//            } else if ((row - 1) == 7) {
//                wenXianCanKaoListVC.wenXianArray = [NSMutableArray arrayWithObjects:@"Lu X, Wang L, Chen S, et al. Genome-wide association study in Han Chinese identifies four new susceptibility loci for coronary artery disease.[J]. Nature Genetics, 2012, 44(8):890-4.", nil];
//            } else if ((row - 1) == 8) {
//                wenXianCanKaoListVC.wenXianArray = [NSMutableArray arrayWithObjects:@"Lu X, Wang L, Chen S, et al. Genome-wide association study in Han Chinese identifies four new susceptibility loci for coronary artery disease.[J]. Nature Genetics, 2012, 44(8):890-4.", nil];
//            } else if ((row - 1) == 9) {
//                wenXianCanKaoListVC.wenXianArray = [NSMutableArray arrayWithObjects:@"Shen G Q, Li L, Rao S, et al. Four SNPs on chromosome 9p21 in a South Korean population implicate a genetic locus that confers high cross-race risk for development of coronary artery disease.[J]. Arteriosclerosis Thrombosis & Vascular Biology, 2008, 28(2):360-5.", nil];
//            }
//            [self.navigationController pushViewController:wenXianCanKaoListVC animated:YES];
//        } else {
//            // 说明不是示例报告
//            WenXianCanKaoListViewController *wenXianCanKaoListVC = [[WenXianCanKaoListViewController alloc] init];
//            wenXianCanKaoListVC.isShiLiBaoGao = NO;
//            if (self.jiYinBiaoGeArray.count > (row-1)) {
//                JiYinJianCeJieGuoModel *model = self.jiYinBiaoGeArray[row-1];
//                wenXianCanKaoListVC.jiYinJianCeJieGuoModel = model;
//            }
//            [self.navigationController pushViewController:wenXianCanKaoListVC animated:YES];
//        }
//    }
}

- (CGFloat)formView:(KWFormView *)formView heightForRow:(NSInteger)row
{
    if (formView.tag == 300) {
        if (row == 0) {
            return 22 * kAdjustParamater;
        } else {
            return 38 * kAdjustParamater;
        }
    } else if (formView.tag == 301) {
        if (row == 0) {
            return 22 * kAdjustParamater;
        } else {
            return 38 * kAdjustParamater;
        }
    }
    
    return 0;
}

- (UIColor *)formView:(KWFormView *)formView colorOfColumn:(NSInteger)column inRow:(NSInteger)row
{
    if (formView.tag == 300) {
        return [UIColor whiteColor];
    } else if (formView.tag == 301) {
        return [UIColor whiteColor];
    }
    return nil;
}

- (UIColor *)formView:(KWFormView *)formView contentColorOfColumn:(NSInteger)column inRow:(NSInteger)row
{
    if (formView.tag == 300) {
        return [UIColor blackColor];
    } else if (formView.tag == 301) {
        return [UIColor blackColor];
    }
    return nil;
}

- (UIColor *)formViewBorderColor:(KWFormView *)formView
{
    if (formView.tag == 300) {
        return kCyanColor;
    } else if (formView.tag == 301) {
        return kCyanColor;
    }
    return nil;
}

- (UIFont *)formViewFontOfContent:(KWFormView *)formView
{
    if (formView.tag == 300) {
        return [UIFont systemFontOfSize:k11Big];
    } else if (formView.tag == 301) {
        return [UIFont systemFontOfSize:k12Big];
    }
    return nil;
}


#pragma mark - 进入圈子
- (void)joinQuanZiOnTianFu:(UIButton *)button
{
    NSLog(@"进入圈子");
    NSString *getQuanZiID = [NSString stringWithFormat:@"%@?token=%@", kZGWGetQuanZiIDByName, kCurrentUserToken];
    NSDictionary *paramaterDic = @{@"name":self.zgwTianFuAndDaiXieModel.name};
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    [manager GET:getQuanZiID parameters:paramaterDic success:^(NSURLSessionDataTask *task, id responseObject) {
        NSDictionary *statusDic = [responseObject valueForKey:@"status"];
        NSString *code = [NSString stringWithFormat:@"%@", [statusDic valueForKey:@"code"]];
        if ([code isEqualToString:@"0"]) {
            NSDictionary *tagDic = [responseObject valueForKey:@"tag"];
            NSLog(@"tagDic = %@", tagDic);
            if ([tagDic isKindOfClass:[NSNull class]]) {
                // 说明为空
                
                [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] addAlertTitle:@"提示" Content: [NSString stringWithFormat:@"%@目前没有对应的圈子", self.zgwTianFuAndDaiXieModel.name] ToView:self];
            } else {
                NSString *quanZiID = [NSString stringWithFormat:@"%@", [tagDic valueForKey:@"id"]];
                NSLog(@"圈子ID：%@", quanZiID);
            }
        }
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] addAlertTitle:@"提示" Content:@"获取圈子信息失败" ToView:self];
    }];
}

#pragma mark - 常见问题
- (void)FAQButton:(UIButton *)button
{
    NSLog(@"常见问题");
    ZGWWebViewController *zgwWebVC = [[ZGWWebViewController alloc] init];
    zgwWebVC.httpUrlString = kZGWFAQUrl;
    [self.navigationController pushViewController:zgwWebVC animated:YES];
}

#pragma mark  - 表格详解
- (void)biaoGeXiangJie:(UIButton *)button
{
    NSLog(@"表格详解");
    ZGWBiaoGeXiangJieViewController *zgwBiaoGeXiangJieVC = [[ZGWBiaoGeXiangJieViewController alloc] init];
    [self.navigationController pushViewController:zgwBiaoGeXiangJieVC animated:YES];
}

- (void)canKaoWenXian:(UIButton *)button
{
    NSLog(@"参考文献");
    ZGWGeneListViewController *zgwGeneListVC = [[ZGWGeneListViewController alloc] init];
        zgwGeneListVC.geneListData = [NSMutableArray arrayWithArray:self.zgwTianFuAndDaiXieModel.geneArray];
    
    [self.navigationController pushViewController:zgwGeneListVC animated:YES];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
